home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Screenblankers / GBlanker / GSource / BGUI / PrefInterp.c < prev    next >
C/C++ Source or Header  |  1996-09-26  |  20KB  |  556 lines

  1. #include <exec/memory.h>
  2. #include <libraries/bgui_macros.h>
  3.  
  4. #include <clib/exec_protos.h>
  5. #include <clib/dos_protos.h>
  6. #include <clib/intuition_protos.h>
  7. #include <clib/bgui_protos.h>
  8. #include <clib/asl_protos.h>
  9. #include "/Libraries/Garshnelib/Garshnelib_protos.h"
  10. #include <clib/alib_protos.h>
  11.  
  12. #include <pragmas/exec_pragmas.h>
  13. #include <pragmas/dos_pragmas.h>
  14. #include <pragmas/intuition_pragmas.h>
  15. #include <pragmas/bgui_pragmas.h>
  16. #include <pragmas/asl_pragmas.h>
  17. #include "/Libraries/Garshnelib/Garshnelib_pragmas.h"
  18.  
  19. #include <ctype.h>
  20. #include <string.h>
  21.  
  22. #include "PrefInterp.h"
  23. #include "/protos/parse.h"
  24. #include "/protos/var.h"
  25. #include "/defs.h"
  26.  
  27. extern struct Library *DOSBase;
  28.  
  29. ULONG Map[] = { SLIDER_Level, INDIC_Level, TAG_END };
  30. struct IBox WinBox, OldBox;
  31. struct Library *IntuitionBase, *BGUIBase, *GarshnelibBase;
  32. Object *ModuleObj, **Objects;
  33. struct Window *ModuleWnd;
  34. struct MsgPort *ReplyPort = 0L;
  35. ULONG ModuleSigs = 0L;
  36. LONG NumGadgets;
  37. VOID *Memory = 0L;
  38. PrefObject *Prefs;
  39.  
  40. STRPTR MakeBoxVarName( STRPTR ProgName, STRPTR IfcName )
  41. {
  42.     static BYTE FileName[108], *Ptr;
  43.  
  44.     strcpy( FileName, ProgName );
  45.     strcat( FileName, "/" );
  46.     strcat( FileName, IfcName );
  47.     if( Ptr = strstr( FileName, ".ifc" ))
  48.         *Ptr = '\0';
  49.     strcat( FileName, ".win" );
  50.     
  51.     return FileName;
  52. }
  53.  
  54. VOID FontRequest( struct TextAttr *Attr )
  55. {
  56.     struct Library *AslBase = OpenLibrary( "asl.library", 37L );
  57.     struct FontRequester *fReq;
  58.  
  59.     if( !AslBase )
  60.         return;
  61.     
  62.     fReq = AllocAslRequestTags( ASL_FontRequest,
  63.                                ASL_FontName, Attr->ta_Name,
  64.                                ASL_FontHeight, Attr->ta_YSize,
  65.                                ASL_MaxHeight, 100, TAG_DONE );
  66.     if( fReq )
  67.     {
  68.         if( AslRequestTags( fReq,
  69.                            ASLFO_Window, ModuleWnd,
  70.                            ASLFO_SleepWindow, TRUE,
  71.                            ASLFO_TitleText, ( LONG )"Please choose a font...",
  72.                            TAG_DONE ))
  73.         {
  74.             CopyMem( fReq->fo_Attr.ta_Name, Attr->ta_Name, 31 );
  75.             Attr->ta_YSize = fReq->fo_Attr.ta_YSize;
  76.         }
  77.         FreeAslRequest( fReq );
  78.     }
  79.  
  80.     CloseLibrary( AslBase );
  81. }   
  82.  
  83. VOID SendMessageToPort( LONG Type, STRPTR PortName )
  84. {
  85.     struct MsgPort *ForeignPort;
  86.     BlankMsg *ClientMsg;
  87.     
  88.     if( ForeignPort = FindPort( PortName ))
  89.     {
  90.         if( ClientMsg = AllocPooled( Memory, sizeof( BlankMsg )))
  91.         {
  92.             ClientMsg->bm_Mess.mn_ReplyPort = ReplyPort;
  93.             ClientMsg->bm_Mess.mn_Length = sizeof( BlankMsg );
  94.             ClientMsg->bm_Type = Type;
  95.             PutMsg( ForeignPort, ( struct Message * )ClientMsg );
  96.         }
  97.     }
  98. }
  99.  
  100. LONG main( LONG argc, STRPTR argv[] )
  101. {
  102.     Object *VertGroup, *SaveBtn, *TestBtn, *CancelBtn, *DisplayBtn, *CtrlGrp;
  103.     Object *NameInf, *SizeInf;
  104.     LONG i, j, LastNonGrp = 0, DispID = -1, Min, Max, *Types, rc, ID, Sigs;
  105.     BYTE DescripName[108], PrefsName[108], BogusBuf[128], ValidPrefs = FALSE;
  106.     STRPTR *Labels, *KeyStrs, BoxVarName;
  107.     ULONG Args[] = { 0L, 0L };
  108.     Object **Indics;
  109.     BPTR Descrip, Tmp;
  110.  
  111.     if( argc != 2 )
  112.         return RETURN_WARN;
  113.     
  114.     if( FindPort( "GarshnePrefs" ))
  115.         return RETURN_WARN;
  116.  
  117.     IntuitionBase = OpenLibrary( "intuition.library", 37 );
  118.     BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION );
  119.     GarshnelibBase = OpenLibrary( "Garshnelib.library", 37 );
  120.  
  121.     if( !IntuitionBase || !BGUIBase || !GarshnelibBase )
  122.         goto JAIL;
  123.     
  124.     if(!( Memory = CreatePool( MEMF_CLEAR, 1024, 512 )))
  125.         goto JAIL;
  126.  
  127.     if(!( ReplyPort = CreatePort( "GarshnePrefs", 0L )))
  128.         goto JAIL;
  129.  
  130.     strcpy( DescripName, argv[1] );
  131.     strcat( DescripName, ".ifc" );
  132.  
  133.     strcpy( PrefsName, argv[1] );
  134.     strcat( PrefsName, ".prefs" );
  135.     
  136.     if(!( Descrip = Open( DescripName, MODE_OLDFILE )))
  137.         goto JAIL;
  138.  
  139.     NumGadgets = ScanDigit( Descrip );
  140.  
  141.     Objects = AllocPooled( Memory, sizeof( Object * ) * ( NumGadgets + 1 ));
  142.     Indics = AllocPooled( Memory, sizeof( Object * ) * ( NumGadgets + 1 ));
  143.     Prefs = AllocPooled( Memory, sizeof( PrefObject ) * ( NumGadgets + 1 ));
  144.     Types = AllocPooled( Memory, sizeof( LONG ) * ( NumGadgets + 1 ));
  145.     KeyStrs = AllocPooled( Memory, sizeof( STRPTR ) * ( NumGadgets + 1 ));
  146.     
  147.     if( !Objects || !Indics || !Prefs || !Types || !KeyStrs )
  148.         goto PREJAIL;
  149.  
  150.     VertGroup = BGUI_NewObject( BGUI_GROUP_GADGET,
  151.                                GROUP_Style, GRSTYLE_VERTICAL,
  152.                                HOffset( 3 ), VOffset( 3 ), Spacing( 3 ),
  153.                                TAG_END );
  154.  
  155.     BoxVarName = MakeBoxVarName( FilePart( argv[0] ), FilePart( argv[1] ));
  156.  
  157.     if( GetVar37( BoxVarName, ( STRPTR )&WinBox, sizeof( struct IBox ),
  158.                  GVF_BINARY_VAR|GVF_DONT_NULL_TERM ) != -1 )
  159.     {
  160.         OldBox = WinBox;
  161.         ModuleObj = BGUI_NewObject( BGUI_WINDOW_OBJECT,
  162.                                    WINDOW_MasterGroup, VertGroup,
  163.                                    WINDOW_Title, FilePart( argv[1] ),
  164.                                    WINDOW_Bounds, &WinBox,
  165.                                    TAG_END );
  166.     }
  167.     else
  168.     {
  169.         ModuleObj = BGUI_NewObject( BGUI_WINDOW_OBJECT,
  170.                                    WINDOW_MasterGroup, VertGroup,
  171.                                    WINDOW_Title, FilePart( argv[1] ),
  172.                                    TAG_END );
  173.     }
  174.         
  175.     if( Tmp = Open( PrefsName, MODE_OLDFILE ))
  176.     {
  177.         Read( Tmp, Prefs, sizeof( LONG )); /* Ignore entry count */
  178.         if( Read( Tmp, Prefs, sizeof( PrefObject ) * NumGadgets ) ==
  179.            sizeof( PrefObject ) * NumGadgets )
  180.             ValidPrefs = TRUE;
  181.         Close( Tmp );
  182.     }
  183.  
  184.     for( i = 0; i < NumGadgets; i++ )
  185.     {
  186.         STRPTR IDStr, LabelStr;
  187.         
  188.         IDStr = ScanToken( Descrip );
  189.         switch( tolower( IDStr[0] ))
  190.         {
  191.         case 'c':
  192.             Types[i] = GAD_CYCLE;
  193.             break;
  194.         case 'd':
  195.             Types[i] = ( tolower( IDStr[1] ) == 'i' )? GAD_DISPLAY : GAD_DELIM;
  196.             break;
  197.         case 'f':
  198.             Types[i] = GAD_FONT;
  199.             break;
  200.         case 's':
  201.             Types[i] = ( tolower( IDStr[1] ) == 'l' )? GAD_SLIDER : GAD_STRING;
  202.             break;
  203.         }
  204.         
  205.         switch( Prefs[i].po_Type = Types[i] )
  206.         {
  207.         case GAD_CYCLE:
  208.             LabelStr = ScanToken( Descrip );
  209.             KeyStrs[i] = ScanToken( Descrip );
  210.             Labels = ScanTokenArray( Descrip );
  211.             if( ValidPrefs )
  212.                 ScanDigit( Descrip );
  213.             else
  214.                 Prefs[i].po_Active = ScanDigit( Descrip );
  215.             Objects[i] =
  216.                 BGUI_NewObject( BGUI_CYCLE_GADGET,
  217.                                GA_ID, i + 10,
  218.                                LAB_Label, LabelStr,
  219.                                LAB_Underscore, '_',
  220.                                FRM_Type, FRTYPE_BUTTON,
  221.                                CYC_Labels, Labels,
  222.                                CYC_Active, Prefs[i].po_Active,
  223.                                TAG_DONE );
  224.             break;
  225.         case GAD_SLIDER:
  226.             LabelStr = ScanToken( Descrip );
  227.             KeyStrs[i] = ScanToken( Descrip );
  228.             Min = ScanDigit( Descrip );
  229.             Max = ScanDigit( Descrip );
  230.             if( ValidPrefs )
  231.                 ScanDigit( Descrip );
  232.             else
  233.                 Prefs[i].po_Level = ScanDigit( Descrip );
  234.             Objects[i] =
  235.                 BGUI_NewObject( BGUI_SLIDER_GADGET,
  236.                                GA_ID, i + 10,
  237.                                LAB_Label, LabelStr,
  238.                                LAB_Underscore, '_',
  239.                                SLIDER_Min, Min, 
  240.                                SLIDER_Max, Max,
  241.                                SLIDER_Level, Prefs[i].po_Level,
  242.                                TAG_DONE );
  243.             Indics[i] =
  244.                 BGUI_NewObject( BGUI_INDICATOR_GADGET,
  245.                                INDIC_Min, Min,
  246.                                INDIC_Max, Max,
  247.                                INDIC_Level, Prefs[i].po_Level,
  248.                                INDIC_Justification, IDJ_CENTER,
  249.                                TAG_DONE );
  250.             break;
  251.         case GAD_FONT:
  252.             if( ValidPrefs )
  253.             {
  254.                 ScanToken( Descrip );
  255.                 ScanDigit( Descrip );
  256.             }
  257.             else
  258.             {
  259.                 strcpy( Prefs[i].po_Name, ScanToken( Descrip ));
  260.                 Prefs[i].po_Attr.ta_YSize = ScanDigit( Descrip );
  261.             }
  262.             Prefs[i].po_Attr.ta_Name = Prefs[i].po_Name;
  263.             Objects[i] =
  264.                 BGUI_NewObject( BGUI_BUTTON_GADGET,
  265.                                GA_ID, i + 10,
  266.                                LAB_Label, "_Font",
  267.                                LAB_Underscore, '_',
  268.                                FRM_Type, FRTYPE_BUTTON,
  269.                                TAG_DONE );
  270.             Args[0] = Prefs[i].po_Attr.ta_YSize,
  271.             Indics[i] =
  272.                 BGUI_NewObject( BGUI_GROUP_GADGET, Spacing( 3 ),
  273.                                StartMember,
  274.                                NameInf =
  275.                                BGUI_NewObject( BGUI_INFO_GADGET,
  276.                                               FRM_Type, FRTYPE_BUTTON,
  277.                                               FRM_Flags, FRF_RECESSED,
  278.                                               INFO_HorizOffset, 6,
  279.                                               INFO_VertOffset, 3,
  280.                                               INFO_TextFormat,
  281.                                               Prefs[i].po_Name,
  282.                                               TAG_DONE ),
  283.                                Weight( 80 ),
  284.                                EndMember,
  285.                                StartMember,
  286.                                SizeInf = 
  287.                                BGUI_NewObject( BGUI_INFO_GADGET,
  288.                                               FRM_Type, FRTYPE_BUTTON,
  289.                                               FRM_Flags, FRF_RECESSED,
  290.                                               INFO_HorizOffset, 6,
  291.                                               INFO_VertOffset, 3,
  292.                                               INFO_TextFormat, "%ld",
  293.                                               INFO_Args, Args,
  294.                                               TAG_DONE ),
  295.                                Weight( 20 ),
  296.                                EndMember,
  297.                                TAG_DONE );
  298.             break;
  299.         case GAD_STRING:
  300.             LabelStr = ScanToken( Descrip );
  301.             KeyStrs[i] = ScanToken( Descrip );
  302.             if( ValidPrefs )
  303.                 FGets( Descrip, BogusBuf, 128 );
  304.             else
  305.             {
  306.                 FGets( Descrip, Prefs[i].po_Value, 128 );
  307.                 Prefs[i].po_Value[strlen( Prefs[i].po_Value )-1] = '\0';
  308.             }
  309.             Objects[i] =
  310.                 BGUI_NewObject( BGUI_STRING_GADGET,
  311.                                GA_ID, i + 10,
  312.                                LAB_Label, LabelStr,
  313.                                LAB_Underscore, '_',
  314.                                FRM_Type, FRTYPE_RIDGE,
  315.                                STRINGA_TextVal, Prefs[i].po_Value,
  316.                                STRINGA_MaxChars, 127,
  317.                                TAG_DONE );
  318.             break;
  319.         case GAD_DISPLAY:
  320.             DispID = i + 10;
  321.             if( ValidPrefs )
  322.                 ScanDigit( Descrip );
  323.             else
  324.             {
  325.                 Prefs[i].po_ModeID = getTopScreenMode();
  326.                 Prefs[i].po_Depth = ScanDigit( Descrip );
  327.             }
  328.             break;
  329.         case GAD_DELIM:
  330.             if( Types[LastNonGrp] == GAD_SLIDER )
  331.                 Objects[i] = BGUI_NewObject( BGUI_GROUP_GADGET, Spacing( 3 ),
  332.                                             StartMember, Objects[LastNonGrp],
  333.                                             Weight( 90 ), EndMember,
  334.                                             StartMember, Indics[LastNonGrp],
  335.                                             Weight( 10 ), EndMember,
  336.                                             TAG_DONE );
  337.             else if( Types[LastNonGrp] == GAD_FONT )
  338.                 Objects[i] = BGUI_NewObject( BGUI_GROUP_GADGET, Spacing( 3 ),
  339.                                             StartMember, Objects[LastNonGrp],
  340.                                             Weight( 20 ), EndMember,
  341.                                             StartMember, Indics[LastNonGrp],
  342.                                             Weight( 80 ), EndMember,
  343.                                             TAG_DONE );
  344.             else
  345.                 Objects[i] = BGUI_NewObject( BGUI_GROUP_GADGET, Spacing( 3 ),
  346.                                             StartMember, Objects[LastNonGrp],
  347.                                             EndMember, TAG_DONE );
  348.             for( j = LastNonGrp + 1; Objects[i] &&( j < i ); j++ )
  349.             {
  350.                 if( Types[j] == GAD_SLIDER )
  351.                 {
  352.                     DoMethod( Objects[i], GRM_ADDMEMBER, Objects[j],
  353.                              LGO_Weight, 90, TAG_END );
  354.                     DoMethod( Objects[i], GRM_ADDMEMBER, Indics[j],
  355.                              LGO_Weight, 10, TAG_END );
  356.                 }
  357.                 else if( Types[j] == GAD_FONT )
  358.                 {
  359.                     DoMethod( Objects[i], GRM_ADDMEMBER, Objects[j],
  360.                              LGO_Weight, 20, TAG_END );
  361.                     DoMethod( Objects[i], GRM_ADDMEMBER, Indics[j],
  362.                              LGO_Weight, 80, TAG_END );
  363.                 }
  364.                 else
  365.                     for( j = LastNonGrp + 1; j < i; j++ )
  366.                         DoMethod( Objects[i], GRM_ADDMEMBER, Objects[j],
  367.                                  TAG_END );
  368.             }               
  369.             LastNonGrp = i+1;
  370.             DoMethod( VertGroup, GRM_ADDMEMBER, Objects[i], TAG_END );
  371.             break;
  372.         default:
  373.             break;
  374.         }
  375.     }
  376.     
  377.     if( Descrip )
  378.     {
  379.         Close( Descrip );
  380.         Descrip = 0L;
  381.     }
  382.  
  383.     if( !ModuleObj )
  384.         goto PREJAIL;
  385.  
  386.     if( DispID != -1 )
  387.     {
  388.         CtrlGrp = HGroupObject, Spacing( 3 ),
  389.         StartMember, SaveBtn = KeyButton( "_Save", ID_SAVE ), EndMember,
  390.         StartMember, TestBtn = KeyButton( "_Test", ID_TEST ), EndMember,
  391.         StartMember, DisplayBtn = KeyButton( "_Display", DispID ), EndMember,
  392.         StartMember, CancelBtn = KeyButton( "_Cancel", ID_CANCEL ), EndMember,
  393.         EndObject;
  394.     }
  395.     else
  396.     {
  397.         CtrlGrp = HGroupObject, Spacing( 3 ),
  398.         StartMember, SaveBtn = KeyButton( "_Save", ID_SAVE ), EndMember,
  399.         StartMember, TestBtn = KeyButton( "_Test", ID_TEST ), EndMember,
  400.         StartMember, CancelBtn = KeyButton( "_Cancel", ID_CANCEL ), EndMember,
  401.         EndObject;
  402.     }
  403.     DoMethod( VertGroup, GRM_ADDMEMBER, CtrlGrp, TAG_END );
  404.  
  405.     GadgetKey( ModuleObj, SaveBtn, "s" );
  406.     GadgetKey( ModuleObj, TestBtn, "t" );
  407.     if( DispID != -1 )
  408.         GadgetKey( ModuleObj, DisplayBtn, "d" );
  409.     GadgetKey( ModuleObj, CancelBtn, "c" );
  410.     
  411.     for( i = 0; i < NumGadgets; i++ )
  412.     {
  413.         switch( Types[i] )
  414.         {
  415.         case GAD_SLIDER:
  416.             AddMap( Objects[i], Indics[i], Map );
  417.         case GAD_CYCLE:
  418.         case GAD_STRING:
  419.             GadgetKey( ModuleObj, Objects[i], KeyStrs[i] );
  420.             break;
  421.         case GAD_FONT:
  422.             GadgetKey( ModuleObj, Objects[i], "f" );
  423.             break;
  424.         default:
  425.             break;
  426.         }
  427.     }
  428.     ModuleWnd = WindowOpen( ModuleObj );
  429.     GetAttr( WINDOW_SigMask, ModuleObj, &ModuleSigs );
  430.  
  431.     while( ModuleObj && ModuleSigs )
  432.     {
  433.         Sigs = Wait( ModuleSigs |( 1L << ReplyPort->mp_SigBit )|
  434.             SIGBREAKF_CTRL_C );
  435.         
  436.         if( Sigs & ( 1L << ReplyPort->mp_SigBit ))
  437.         {
  438.             BlankMsg *FreeMe;
  439.  
  440.             while( FreeMe = ( BlankMsg * )GetMsg( ReplyPort ))
  441.             {
  442.                 switch( FreeMe->bm_Type )
  443.                 {
  444.                 case BM_DOQUIT:
  445.                     FreeMe->bm_Flags |= BF_REPLY;
  446.                     ReplyMsg(( struct Message * )FreeMe );
  447.                     ModuleSigs = 0L;
  448.                     break;
  449.                 case BM_RELOADPREFS:
  450.                 case BM_SENDTEST:
  451.                     FreePooled( Memory, FreeMe, sizeof( BlankMsg ));
  452.                     break;
  453.                 }
  454.             }
  455.         }
  456.  
  457.         if( Sigs & SIGBREAKF_CTRL_C )
  458.         {
  459.             ModuleSigs = 0L;
  460.             break;
  461.         }
  462.         
  463.         do
  464.         {
  465.             switch( rc = HandleEvent( ModuleObj ))
  466.             {
  467.             case ID_SAVE:
  468.                 if( Tmp = Open( PrefsName, MODE_NEWFILE ))
  469.                 {
  470.                     Write( Tmp, &NumGadgets, sizeof( LONG ));
  471.                     Write( Tmp, Prefs, sizeof( PrefObject ) * NumGadgets );
  472.                     Close( Tmp );
  473.                 }
  474.                 SendMessageToPort( BM_RELOADPREFS, "GarshneClient" );
  475.                 GetAttr( WINDOW_Bounds, ModuleObj, ( ULONG * )&WinBox );
  476.                 if( memcmp( &OldBox, &WinBox, sizeof( struct IBox )))
  477.                     SetVar37( BoxVarName, ( STRPTR )&WinBox,
  478.                              sizeof( struct IBox ), GVF_BINARY_VAR|
  479.                              GVF_DONT_NULL_TERM|GVF_SAVE_VAR|GVF_GLOBAL_ONLY );
  480.             case ID_CANCEL:
  481.             case WMHI_CLOSEWINDOW:
  482.                 ModuleSigs = 0L;
  483.                 break;
  484.             case ID_TEST:
  485.                 if( Tmp = Open( "T:GBlankerTmpPrefs", MODE_NEWFILE ))
  486.                 {
  487.                     Write( Tmp, &NumGadgets, sizeof( LONG ));
  488.                     Write( Tmp, Prefs, sizeof( PrefObject ) * NumGadgets );
  489.                     Close( Tmp );
  490.                     SendMessageToPort( BM_SENDTEST, "GarshneServer" );
  491.                 }
  492.                 break;
  493.             default:
  494.                 ID = rc - 10;
  495.                 if( rc > 9 && ID < NumGadgets )
  496.                 {
  497.                     switch( Types[ID] )
  498.                     {
  499.                     case GAD_CYCLE:
  500.                         GetAttr( CYC_Active, Objects[ID],
  501.                                 ( ULONG * )&Prefs[ID].po_Active );
  502.                         break;
  503.                     case GAD_SLIDER:
  504.                         GetAttr( SLIDER_Level, Objects[ID],
  505.                                 ( ULONG * )&Prefs[ID].po_Level );
  506.                         break;
  507.                     case GAD_STRING:
  508.                     {
  509.                         STRPTR TmpPtr;
  510.                         
  511.                         GetAttr( STRINGA_TextVal, Objects[ID],
  512.                                 ( ULONG * )&TmpPtr );
  513.                         strcpy( Prefs[ID].po_Value, TmpPtr );
  514.                         break;
  515.                     }
  516.                     case GAD_FONT:
  517.                         FontRequest( &Prefs[ID].po_Attr );
  518.                         SetAttrs( NameInf, INFO_TextFormat, Prefs[ID].po_Name,
  519.                                  TAG_DONE );
  520.                         Args[0] = Prefs[ID].po_Attr.ta_YSize;
  521.                         SetAttrs( SizeInf, INFO_Args, Args, TAG_DONE );
  522.                         break;
  523.                     case GAD_DISPLAY:
  524.                         ScreenModeRequest( ModuleWnd, &Prefs[ID].po_ModeID,
  525.                                           Prefs[ID].po_Depth ?
  526.                                           &Prefs[ID].po_Depth : 0L );
  527.                         break;
  528.                     }
  529.                 }
  530.                 break;
  531.             }
  532.         }
  533.         while( rc != WMHI_NOMORE );
  534.     }
  535.  
  536.     DisposeObject( ModuleObj );
  537.     
  538.  PREJAIL:
  539.     if( Descrip )
  540.         Close( Descrip );
  541.  
  542.  JAIL:
  543.     if( ReplyPort )
  544.         DeletePort( ReplyPort );
  545.     if( Memory )
  546.         DeletePool( Memory );
  547.     if( GarshnelibBase )
  548.         CloseLibrary( GarshnelibBase );
  549.     if( BGUIBase )
  550.         CloseLibrary( BGUIBase );
  551.     if( IntuitionBase )
  552.         CloseLibrary( IntuitionBase );
  553.  
  554.     return RETURN_OK;
  555. }
  556.